//LuoguUid:397712
//UserName:dingyibo

/*
<Dragohearted> I have the same name novel in my luogu home page
Lost but marching on, like we've always know the trail
Searching for out ending to the fairy tale
Sometimes even shooting stars
Find wishes but miss their marks
But when the night gets too dark
And the road homeseems too far
We'll see the sun come up again
We'll climb higher than we been
We got a fire that burns within
We are the dragonhearted
We are the dragonhearted
Courage to stop a cannon ball
Together we stand 30 feets tall
We got a fire that burns within
We are the dragonhearted
Fearless we soar, speeding arrows regorshet
Break free, our hearts burn brighter than yesterday
And through the battles we wage
When our shields fall away
The armor cracks and breaks
If ever our torch is fade
We'll see the sun come up again
We'll climb higher than we been
We got a fire that burns within
We are the dragonhearted
We are the dragonhearted
Courage to stop a cannon ball
Together we stand 30 feets tall
We got a fire that burns within
We are the dragonhearted
Standing tall, forever united
We are the dragonhearted
We are the dragonhearted
Oh
We are the dragonhearted
We are the dragonhearted
*/

#include <bits/stdc++.h>

#define MAX_N 100050
#define INF 2147483647

using namespace std;

int n, m, L, V;
int d[MAX_N], v[MAX_N], a[MAX_N];
int p[MAX_N];
int T;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    // Only For Special A->a[i] = 0

    cin>>T;

    while(T--)
    {
        int i;
        int upspeed = 0;
        //int del_upspeed = 0;

        cin>>n>>m>>L>>V;

        for(i=1;i<=n;++i)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        for(i=1;i<=m;++i)
        {
            cin>>p[i];
        }

        for(i=1;i<=n;++i)
        {
            if(d[i] <= p[m] && v[i] > V)
                ++upspeed;
        }
        
        cout<<upspeed<<' ';
        if(upspeed == 0)
            cout<<m<<'\n';
        else
            cout<<m-1<<'\n';
        
    }

    return 0;
}
